home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / RCS / texps.lpro,v < prev   
Encoding:
Text File  |  1990-11-20  |  3.7 KB  |  123 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.1
  10. date     90.11.13.10.24.15;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @original
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @% PostScript prolog for using resident fonts.
  27. % No change is made to the encoding scheme, since `virtual fonts' do that
  28. % better. All we do is change the widths so that PostScript positioning
  29. % matches the assumptions of dvips.
  30.  
  31. % The calling sequence defining font foo to be resident font Bar is
  32. %           /foo [wd0 wd1 ... wd255] /Bar mag atsize rf
  33. % where each character width wdi is in pixels,
  34. % mag is the magnification per thousand,
  35. % and atsize is the desired font size in TeX scaled points (sp).
  36.  
  37. %
  38. TeXDict begin
  39. %
  40. /rf {
  41. 655360 div mul Resolution mul 7227 div /PixPerEm exch def % compute pixels/em
  42. % We copy everything but the FID entry of the resident font
  43. % (just as in section 5.7 of the Red Book)
  44. findfont
  45. dup length 1 add dict /newfont exch def
  46.    {1 index /FID ne
  47.       {newfont 3 1 roll put}
  48.       {pop pop}
  49.       ifelse
  50.    } forall
  51. % Now the top entry on the stack is the array of pixel widths.
  52. % We convert them to PostScript's milli-em units, and put them
  53. % in a Metrics dictionary.
  54.   256 dict begin
  55.      newfont /Encoding get
  56.      0 1 255 {
  57.        2 copy get
  58.        3 index 2 index get 
  59.        1000 mul PixPerEm div def pop
  60.      } for
  61.   pop pop
  62.   newfont /Metrics currentdict put end
  63. % Finally we associate the new font with a name like ZZfoo@@,
  64. % using conventions identical to those of downloaded bitmap fonts.
  65.    /fontname exch def
  66.    dmystr 2 fontname cvx (@@@@@@@@) cvs putinterval  % put name in template
  67.    newname dup newfont definefont
  68.    [PixPerEm 0 0 PixPerEm neg 0 0] makefont def
  69.    fontname { /foo setfont }       %  dummy macro to be filled in
  70.       2 array copy cvx def         %  have to allocate a new one
  71.    fontname load                   %  now we change it
  72.       0 dmystr 6 string copy       %  get a copy of the font name
  73.       cvn cvx put                  %  and stick it in the dummy macro
  74. } bdf
  75.  
  76. %
  77. %   Now here's some oblique hackery... an example of making
  78. %   variants of a resident font look like it is resident.
  79. %   Say, e.g., /Times-Slanted /Times-Roman .167 SlantFont
  80. %   to make /Times-Slanted a font with slant of 1/6;
  81. %   or /Times-Extended /Times-Roman 1.05 ExtendFont
  82. %   to make a font that's 5% wider.
  83. %   Optionally replace the `slant' by `angle ObliqueSlant';
  84. %   note that the ObliqueSlant of Times-Italic is -15.5 (negative).
  85. %
  86. /ObliqueSlant {   % angle ObliqueSlant slant
  87.     dup sin exch cos div neg
  88.     } bdf
  89.  
  90. /SlantFont {      % fontname basefontname slant SlantFont pseudoresfontname
  91.     /foo exch def
  92.     [1 0 foo 1 0 0] TransFont
  93.     } bdf
  94.  
  95. /ExtendFont {     % widtharray fontname basefontname factor ExtendFont
  96.                   %     widtharray' pseudoresfontname
  97.     /foo exch def
  98.     3 2 roll [ exch {foo div} forall ] % divide each width entry by the factor
  99.     3 1 roll [foo 0 0 1 0 0] TransFont
  100.     } bdf
  101.  
  102. % Note: After Times-Slanted is declared once as a SlantFont, you can
  103. % use it again without redeclaring its relation to Times-Roman.
  104. % But this doesn't work with Times-Extended, because you have to
  105. % recompute the widths for each incarnation of Times-Extended.
  106. % In fact, strictly speaking, it doesn't work even with Times-Slanted,
  107. % because the widths are rounded differently at different sizes.
  108. % Therefore dvips repeats the special instructions each time.
  109.  
  110. /TransFont {      % fontname basefontname matrix TransFont pseudoresfontname
  111.     exch findfont exch makefont
  112.     dup length dict /newfont exch def
  113.        {1 index /FID ne
  114.           {newfont 3 1 roll put}
  115.           {pop pop}
  116.        ifelse
  117.        } forall
  118.     dup newfont definefont pop
  119.     } bdf
  120. %
  121. end
  122. @
  123.